package variableparameter;

import java.util.ArrayList;

public class MyVariableParameter1 {
    public static void main(String[] args) {
        int sum = getSum(1,2,3,4,5);
        System.out.println(sum);
        int [] arr = {1,2,3,4,5};
        System.out.println(getSum(arr));
    }

    private static int getSum(int... arr) {
        int num = 0;
        for (int i = 0; i < arr.length; i++) {
            num+=arr[i];
        }
        return num;
    }
}
